package org.xfl.loan;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class BankActivity extends Activity {
	private double dResult;
	private EditText moneyEdit;
	private EditText rateEdit;
	private EditText monthEdit;
	private TextView showTotalMoneyView;
	private static double inputMoney;
	private double inputRate;
	private double inputMonth;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.loan_rate);
        Button calButton = (Button) findViewById(R.id.cal_button);
        showTotalMoneyView = (TextView) findViewById(R.id.total_money_id);
        calButton.setOnClickListener(new OnClickListener() {
		
			@Override
			public void onClick(View v) {
				moneyEdit = (EditText) findViewById(R.id.amount_edit_id);
				rateEdit = (EditText) findViewById(R.id.loan_edit_id);
				monthEdit = (EditText) findViewById(R.id.month_edit_id);
				inputMoney = Double.parseDouble(moneyEdit.getText().toString());
				inputRate = Double.parseDouble(rateEdit.getText().toString());
				inputMonth = Double.parseDouble(moneyEdit.getText().toString());
				System.out.println(inputMoney);
				System.out.println(inputRate);
				dResult = calTotalMoney(inputMoney,inputRate,inputMonth);
				System.out.println(dResult);
				showTotalMoneyView.setText(String.valueOf(dResult));
				
			}
		});
        
    }
    
    public static double calTotalMoney(double money,double rate,double month)
    {
    	double dans = 0;
    	dans = money*rate*0.01*month+inputMoney;
    	
    	return dans;
    	
    }
    
    public static boolean verifyData(String value1,String value2)
    {
    	boolean bAns = false;
    	
    	return bAns;
    }
}